package com.ysc.task.config;

import com.ysc.task.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Version: 1.0
 * Class Name: WebConfig
 * Description: TODO(一句话描述功能)
 * Author: ysc
 * Date: 2024/3/31 18:21
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册TestInterceptor拦截器
        registry.addInterceptor(loginInterceptor())
                .excludePathPatterns("/user/login")				//添加不拦截的请求路径
                .excludePathPatterns("/user/register")
                .addPathPatterns("/**");						//添加需要拦截的路径
    }

    @Bean
    public LoginInterceptor loginInterceptor(){
        return new LoginInterceptor();
    }
}
